<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>发帖页面</title>
        <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
        <script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
//      	$(document).ready(function(){
//      		$("a").click(function(){
//      			var title=$("input[name=title]").val();
//      			var filee=$("input[name=file]").val();
//     		 		var txt=$("textarea[name=txt]").val();
//     		 		var selec=$("select[name=select]").val();
//      			$.ajax({
//      				type:"post",
//      				url:"/forum/postServlet",
//      				async:true,
//      				data:$("form").serialize(),
//      				success:function(){
//      					alert("发帖成功。。。")
//      				}
//      			});
//      		})
//      	})
        </script>
    </head>
    <body>
    	<div class="post">
    		<form>
				<div class="form-group">
					<label>标题：</label>
					<input type="text" name="title" maxlength="11" />
				</div>
				
				<div class="form-group">
					<label>文件上传：</label>
					<input type="file" name="file" contenteditable="false"/>
				</div>
				
				<div class="form-group">
					<label>输入内容：</label>
					<textarea class="form-control" name="txt" rows="8"></textarea>
				</div>
				<div class="form-group">
					<label>板块：</label>
					<select name="select" style="width: 70px;height: 30px;">
						<option>生活</option>
						<option>学习</option>
						<option>工作</option>
					</select>
				</div>
			</form>
    		
    		<div class="foot">
    			<div class="btn" >
    				<a class="btn btn-primary" id="sub">确认发帖</a>
    			</div>
    		</div>
    		<!-- <a href="http://127.0.0.1:8080/forum/FileUploadServlet">请求</a> -->
    	</div>
    	<script type="text/javascript">
    		$(".post").css({"width":"670px","margin":"auto"});
    		$(".foot").css({"width":"670px","margin":"auto"});
    		$(".btn").css({"float":"right"});
    		
    		window.onload=function(){
    			$("#sub").click(function(){
					$.ajax({
						type:"post",
						url:"FileUploadServlet",
						async:true,
						data:new FormData($("form")[0]),
						enctype:"multipart/form-data",
						processData:false, //告诉ajax不要在处理FromData处理好的数据
						contentType:false,//设置ajax请求头ContentType为false，禁用
						success:function(){
								alert("发帖成功，即将跳到主界面");
								window.location.href="bbs.jsp";
						}
					});
    			})
    		}
    	</script>
 	</body>
</html>